<?php
	session_start();
	
	//checks if user has logged in and if not displays an error message
	if(!isset($_SESSION['username']))
	{
		$_SESSION['message'] = "<span style='color: red; font-weight: bold;'>You are not logged in to view this page.</span>";
		header('Location: login');
	}
?>

<html>
	<head>
		<title>Shopping Cart</title>
	</head>
	<body>
		<p align="left">User: <?php echo $_SESSION['username'];?></p>
		<p>
			<?php
				if(isset($_POST['itemNumber']))
				{
					$item = $_POST['itemNumber'];
					$_SESSION['array'][$item] = $item;
				}
  
				if(isset($_SESSION['array'])) 
				{
					foreach($_SESSION['array'] as $key) 
					{
						echo 'you have item ' . $_SESSION['array'][$key] . ' in your cart<br />';
					}    
				} 
				else
				{
					echo 'your shopping cart is empty';
				}
			?>
		</p>
	</body>
</html>